GNUPro Toolkit Documentation|Index|Next
Using `diff` & `patch`

Comparing and merging files
`diff`, `diff3`, `sdiff`, `cmp`,
and `patch` 1.3, `diff` 2.7
and `patch` 2.1

    Copyright © 1992, 1993, 1994, 1995, 1996  Free Software Foundation, Inc.

    Permission is granted to make and distribute verbatim copies of this documentation provided
    the copyright notice and this permission notice are preserved on all copies.

    Permission is granted to copy and distribute modified versions of this documentation
    under the conditions for verbatim copying, provided also that the entire resulting derived work
    is distributed under the terms of a permission notice identical to this one.

    Permission is granted to copy and distribute translations of this documentation into
    another language, under the above conditions for modified versions.

    GNU diff was written by Mike Haertel, David Hayes, Richard Stallman, Len Tower, and
    Paul Eggert. Wayne Davison designed and implemented the unified output format.

    The basic algorithm is described in "An O(ND) Difference Algorithm and its Variations"
    by Eugene W. Myers, in Algorithmica; Vol. 1, No. 2, 1986; pp. 251–266; and in "A File
    Comparison Program" by Webb Miller and Eugene W. Myers, in Software—Practice and
    Experience; Vol. 15, No. 11, 1985; pp. 1025–1040.

    The algorithm was independently discovered as described in "Algorithms for Approximate
    String Matching" by E. Ukkonen, in Information and Control; Vol. 64, 1985, pp. 100–118.

    GNU diff3 was written by Randy Smith.

    GNU sdiff was written by Thomas Lord.

    GNU cmp was written by Torbjorn Granlund and David MacKenzie.

    patch was written mainly by Larry Wall; the GNU enhancements were written mainly
    by Wayne Davison and David MacKenzie.

    Parts of this manual are adapted from a manual page written by Larry Wall, with his
    permission.

    This documentation has been prepared byCygnus Technical Publications;
    to contact the Cygnus Solutions Documentation staff, email: doc@cygnus.com.

    Copyright © 1994, 1995, 1996, 1997  Cygnus Solutions. All rights reserved.

    GNUPro™, the GNUPro™ logo are trademarks of Cygnus Solutions.
    All other brand and product names are trademarks of their respective owners.

The following documentation discusses comparing and merging files.

- Overview of Comparing and Merging Files

- What Comparison Means

- Hunks
- Suppressing Differences in Blank and Tab Spacing
- Suppressing Differences in Blank Lines
- Suppressing Case Differences
- Suppressing Lines Matching a Regular Expression
- Summarizing Which Files Differ
- Binary Files and Forcing Text Comparisons

- diff Output Formats

- Two Sample Input Files
- Showing Differences Without Context

- Detailed Description of Normal Format
- An Example of Normal Format

- Showing Differences in Their Context

- Context Format
- Unified Format
- Showing Which Sections Differences Are in
- Showing Alternate File Names

- Showing Differences Side by Side
- Controlling Side by Side Format

- An Example of Side by Side Format

- Making Edit Scripts

- ed Scripts
- Forward ed Scripts
- RCS Scripts

- Merging Files with If-then-else

- Line Group Formats
- Line Formats
- Detailed Description of If-then-else Format
- An Example of If-then-else Format

- Comparing Directories
- Making diff Output Prettier

- Preserving Tabstop Alignment
- Paginating diff Output

- diff Performance Tradeoffs
- Comparing Three Files

- A Third Sample Input File
- Detailed Description of diff3 Normal Format

- diff3 Hunks

- An Example of diff3 Normal Format

- Merging From a Common Ancestor

- Selecting Which Changes to Incorporate
- Marking Conflicts
- Generating the Merged Output Directly
- How diff3 Merges Incomplete Lines
- Saving the Changed File

- Interactive Merging with sdiff

- Specifying diff Options to sdiff
- Merge Commands

- Merging with patch

- Selecting the patch Input Format
- Applying Imperfect Patches

- Applying Patches with Changed White Space
- Applying Reversed Patches
- Helping patch Find Inexact Matches

- Removing Empty Files
- Multiple Patches in a File
- Messages and Questions from patch

- Tips for Making Patch Distributions
- Invoking cmp

- Options to cmp

- Invoking diff

- Options to diff

- Invoking diff3

- Options to diff3

- Invoking patch

- Applying Patches in Other Directories
- Backup File Names
- Reject File Names
- Options to patch

- Invoking sdiff

- Options to sdiff

- Incomplete Lines
- Future Projects

- Handling Changes to the Directory Structure
- Files that are Neither Directories Nor Regular Files
- File Names that Contain Unusual Characters
- Arbitrary Limits
- Handling Files that Do Not Fit in Memory
- Ignoring Certain Changes

- Reporting Bugs

- Index

Top|Next